package org.micro.rbac.core.model;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.micro.rbac.core.constant.Global;

import java.io.Serial;


/**
 * @author hongsir
 * @apiNote 摘要:持久层入参,用户mapper查询
 * @since 2019-03-14 12:40
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class BasePageForm extends BaseQueryForm {
    @Serial
    private static final long serialVersionUID = -5138460298353767452L;

    @Min(value = 1, message = "页码最小值为{value}")
    @Schema(description = "当前页")
    private Integer pageNum = Global.PAGE_NUM_DEFAULT;

    @Max(value = 500, message = "页容量最大值为{value}")
    @Min(value = 1, message = "页容量最小值为{value}")
    @Schema(description = "页容量")
    private Integer pageSize = Global.PAGE_SIZE_DEFAULT;

    public Integer getPageNum() {
        return pageNum == null ? Global.PAGE_NUM_DEFAULT : pageNum;
    }

    public Integer getPageSize() {
        return pageSize == null ? Global.PAGE_SIZE_DEFAULT : pageSize;
    }
}
